package com.janchow.whisper.common.api.consumer;

import com.janchow.whisper.common.api.ISayHelloService;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Jange on 2016/5/24.
 */
public class SayHelloAction {

    private ISayHelloService sayHelloService;

    public void setSayHelloService(ISayHelloService sayHelloService) {
        this.sayHelloService = sayHelloService;
    }

    public void start() throws Exception {
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            try {
                String hello = sayHelloService.sayHello("world" + i);
                System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] " + hello);
            } catch (Exception e) {
                e.printStackTrace();
            }

            Thread.sleep(2000);
        }
    }

}
